package org.inspursc.s0517.health.evaluation.converter;

import com.alibaba.fastjson.JSON;
import org.inspursc.s0517.health.evaluation.dto.*;
import org.inspursc.s0517.health.evaluation.entity.InsSurveyAnswer;
import org.springframework.beans.BeanUtils;

/**
 * institution assessment
 */
public class InsSurveyAnswerConverter {

    /**
     * convert for save assessment result
     */
    public static InsSurveyAnswer converter(InsSurveyAnswerDTO insSurveyAnswerDTO){
        InsSurveyAnswer insSurveyAnswer = new InsSurveyAnswer();
        BeanUtils.copyProperties(insSurveyAnswerDTO, insSurveyAnswer);
        return insSurveyAnswer;
    }

    /**
     * convert for return report
     */
    public static InsSurveyAnswerGradeDTO insConverterToGrade(InsSurveyAnswer insSurveyAnswer) {
        InsSurveyAnswerGradeDTO insSurveyAnswerGradeDTO = new InsSurveyAnswerGradeDTO();
        BeanUtils.copyProperties(insSurveyAnswer, insSurveyAnswerGradeDTO);
        insSurveyAnswerGradeDTO.setKpi(JSON.parseObject(insSurveyAnswer.getKpi()));
        return insSurveyAnswerGradeDTO;
    }

    public static InsSurveyAnswerDTO converter(InsSurveyAnswer an) {
        InsSurveyAnswerDTO anDTO = new InsSurveyAnswerDTO();
        BeanUtils.copyProperties(an, anDTO);

        return anDTO;
    }
}
